import Vue from "vue";
import VueRouter from "vue-router";
import DashboardLayout from "@/pages/Layout/DashboardLayout.vue";
import Dashboard from "@/pages/Dashboard.vue";
import Icons from "@/pages/Icons.vue";
import Maps from "@/pages/Maps.vue";
import Notifications from "@/pages/Notifications.vue";
import UserProfile from "@/pages/UserProfile.vue";
import TableList from "@/pages/TableList.vue";
import Typography from "@/pages/Typography.vue";

import Login from "@/pages/Login/Login"
import page404 from "@/pages/error/404"
import UpdateAvatar from "@/pages/UpdateAvatar"

import security from "./modules/Security";
import user from "./modules/User"
import swagger from "./modules/Swagger"

Vue.use(VueRouter);
export const routes = [
  {
    path: "/login",
    name: "Login",
    component: Login,
  },
  {
  path: "/",
  component: DashboardLayout,
  redirect: "/dashboard",
  children:[
    {
      path: "/dashboard",
      name: "主页",
      component: Dashboard,
      meta: {
        title: "主页",
      }
    },
    {
      path: "/icons",
      name: "图标库",
      component: Icons,
      meta: {
        title: "图标库",
      }
    },
    {
      path: "/maps",
      name: "ip从属",
      component: Maps,
      meta: {
        title: "ip从属",
      }
    },
    {
      path: "/table",
      name: "Table List",
      component: TableList
    },
  ]
},
  {
    path: "/404",
    name: "404",
    component: page404
  },
  {
    path: "/updateAvatar",
    name: "UpdateAvatar",
    component: UpdateAvatar
  }
];

// 私有路由表
export const privateRoutes = [
  security,
  user,
  swagger
];
const router = new VueRouter({
  mode: "hash",
  base: process.env.BASE_URL,
  routes: [...routes],
});

Vue.use(VueRouter);
const VueRouterPush = VueRouter.prototype.push;
VueRouter.prototype.push = function push(to) {
  return VueRouterPush.call(this, to).catch((err) => err);
};

export default router;
